home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 25
/
Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso
/
Aminet
/
comm
/
net
/
AMarquee1_48.lha
/
AMarquee
/
examples
/
amarqueehost.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1998-04-10
|
6KB
|
166 lines
/*************************************************
AMarqueeHost.rexx
Author: Jeremy Friesner (jaf@chem.ucsd.edu)
An ARexx implementation of AMarqueeHost.c. Works pretty much
the same as the C version does! Requires amarquee.library
v46 or higher.
Usage: rx AMarqueeHost.rexx [serverName] [portNumber] [logName]
***************************************************/
parse arg hostnames lognames portNum .
if (serverName == '?') then do
say "Usage: rx AMarqueeHost.rexx [hostnames] [lognames] [port]"
say " (defaults args are #? #? 0)"
exit
end
if (length(hostnames) = 0) then hostnames = '#?'
if (length(lognames) = 0) then lognames = '#?'
if (length(portNum) = 0) then portNum = 0
/* We need to trap all the different ways the script could exit,
so that we can be sure any allocated QSessions or QMessages are
freed properly */
signal on error
signal on syntax
signal on halt
signal on break_c
signal on break_f
/* Used to track allocated QSession and QMessage */
session = 0
message = 0
/* Note the offset MUST be -204, and not -30 like in many other
libraries! Note also that we require amarquee.library v46 or higher */
check = addlib('amarquee.library', 0, -204, 46)
session = QNewHostSession(hostnames, portNum, lognames)
if (session > 0) then
do
portNum = word(session, 2)
say "Waiting for connections from /" || hostnames || "/" || lognames || " on port " || portNum || "."
say "(Try running: AMarqueeDebug localhost test " || portNum || ")"
say ""
say "Commands are:"
say ""
say "a wildhostpath Access control (default is /#?/#?)"
say "A wildhostpath Access control for incoming messages (default in no access)"
say "m hosts=arg2 Send an active message to hosts"
say "M hosts=string Send an system message to hosts"
say "s path=arg2 Set arg2 node value"
say "S path=arg2 Stream arg2 node value"
say "r path=newlabel Rename arg2 node"
say "D debugstring Send debug string"
say "g wildpath Get a node or nodes"
say "c wildpath Subscribe to a node or nodes"
say "C wildpath Get&Subscribe to a node or nodes"
say "k opID Klear subscriptions (by id or 0 for all)"
say "d wildpath Delete a node or nodes"
say "i Request info packet"
say "p Request ping packet"
say "v # Request new privileges (by code bitchord)"
say "w # Release existing privileges (by code bitchord)"
say "! hosts Kill other clients (requires KILLCLIENTS privilege!)"
say "$ param=string Set a parameter with QSetParam()"
say "? param Get a parameter by name"
say "<enter> Send accumulated transactions (GO!!)"
say ""
say "Press CTRL-F to enter commands, or CTRL-C to quit"
MainLoop:
do forever=1
/* This will block until we get a signal (e.g. CTRL-C) or a QMessage
arrives over our connection. */
message = GetNextQMessage(session)
if (message > 0) then do
say "QMessage received---------"
say "Status: " || GetQMessageField(message, 'Status') || " (" || QErrorName(GetQMessageField(message, 'Status')) || ")"
say "Error Line: " || GetQMessageField(message, 'ErrorLine')
say "Message ID: " || GetQMessageField(message, 'ID')
say "Path: " || GetQMessageField(message, 'Path')
say "Data: " || GetQMessageField(message, 'Data')
say "DataLen: " || GetQMessageField(message, 'DataLen')
say "ActualLen: " || GetQMessageField(message, 'ActualLen')
call FreeQMessage(session, message)
message = 0
end /* (message > 0) */
else
do
say "GetNextQMessage returned NULL... probably because we caught a signal."
end
end /* (session > 0) */
end
else say "Couldn't connect to server, sorry."
/* Our error handling/cleanup routine starts here */
ERROR:
SYNTAX:
HALT:
BREAK_C:
say "CTRL-C or error detected in line " || sigl
if (message > 0) then do
call FreeQMessage(session, message)
end
if (session > 0) then do
call QFreeSession(session)
end
exit
/* Command processsing "subroutine" */
BREAK_F:
say "CTRL-F detected, now reading user commands from console."
done = 0
do while (done = 0)
say "Enter next command, or just press enter to send all queued commands."
parse pull cmd args .
if (length(cmd) = 0) then
do
call QGo(session, 0)
done = 1
end
else
do
/* parse out args if there is an = sign */
parse var args arg1 '=' arg2
res = -100
if (cmd = 'A') then res=QSetMessageAccessOp(session, arg1)
else if (cmd = 'm') then res=QMessageOp(session, arg1, arg2)
else if (cmd = 'M') then res=QSysMessageOp(session, arg1, arg2)
else if (cmd = 'a') then res=QSetAccessOp(session, arg1)
else if (cmd = 's') then res=QSetOp(session, arg1, arg2)
else if (cmd = 'S') then res=QStreamOp(session, arg1, arg2)
else if (cmd = 'r') then res=QRenameOp(session, arg1, arg2)
else if (cmd = 'D') then res=QDebugOp(session, arg1)
else if (cmd = 'g') then res=QGetOp(session, arg1)
else if (cmd = 'd') then res=QDeleteOp(session, arg1)
else if (cmd = 'i') then res=QInfoOp(session)
else if (cmd = 'c') then res=QSubscribeOp(session, arg1)
else if (cmd = 'C') then res=QGetAndSubscribeOp(session, arg1)
else if (cmd = 'k') then res=QClearSubscriptionsOp(session,arg1)
else if (cmd = 'p') then res=QPingOp(session)
else if (cmd = 'v') then res=QRequestPrivilegesOp(session,arg1)
else if (cmd = 'w') then res=QReleasePrivilegesOp(session,arg1)
else if (cmd = '!') then res=QKillClientsOp(session,arg1)
else if (cmd = '?') then res=QGetParameterOp(session,arg1)
else if (cmd = '$') then res=QSetParameterOp(session,arg1,arg2)
if (res = -100) then say "Unknown command character [" || cmd || "]"
else say "Command processed, opCode was " || res
end
end
say "Sending commands and resuming main loop..."
signal on break_f
signal MainLoop